package com.enhe.gck.enums;

import com.enhe.gck.CarbonEnumKeyValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 订单状态枚举
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum {


    Created(CarbonEnumKeyValue.订单记录_状态_已创建_ycj, "已创建"),
    Pending_First_Weigh(CarbonEnumKeyValue.订单记录_状态_待过一磅_dgyb, "待过一磅"),
    Pending_Loading(CarbonEnumKeyValue.订单记录_状态_待装卸货_dzxh, "待装卸货"),
    Pending_Second_Weigh(CarbonEnumKeyValue.订单记录_状态_待过二磅_dgeb, "待过二磅"),
    Pending_Return_Card(CarbonEnumKeyValue.订单记录_状态_待归还卡_dghk, "待归还卡"),
    Leaving_Factory(CarbonEnumKeyValue.订单记录_状态_已出厂_ycc, "已出厂"),
    ;

    private Long code;
    private String name;

    /**
     * 通过code获取name
     */
    public static String getNameByCode(Long code) {
        return Arrays.stream(OrderStatusEnum.values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("未找到对应的订单枚举值"))
                .getName();
    }

}
